package com.example.neteasecloudmusic.view;

import android.graphics.Rect;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

public class LinearSpaceItemDecoration extends RecyclerView.ItemDecoration {

    private int mSpace;

    public LinearSpaceItemDecoration (int space) {
        mSpace = space;
    }

    /**
     * @param outRect: Item's Rect border
     * @param view: ItemView
     * @param parent: RecycleView
     * @param state: RecycleView's state
     */
    @Override
    public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
        super.getItemOffsets(outRect, view, parent, state);
        outRect.left = mSpace;
        if (parent.getChildAdapterPosition(view) % 6 == 5) {
            outRect.right = mSpace;
        }

    }
}
